/*
 * @Author: LiYu
 * @Date: 2022-04-03 20:43:38
 * @LastEditors: LiYu
 * @LastEditTime: 2022-04-03 23:05:30
 * @Description: 
 */
class ScorePanel {
  score = 0;
  level = 1;

  scoreEl: HTMLElement;
  levelEl: HTMLElement;

  maxLevel: number;
  upScore: number;


  constructor(maxLevel: number = 10, upScore: number = 2) {
    this.maxLevel = maxLevel;
    this.upScore = upScore;
    this.scoreEl = document.querySelector('.score')!;
    this.levelEl = document.querySelector('.level')!;
  }

  addScore() {
    this.score ++;
    this.scoreEl.innerText = this.score + '';
    if(this.score % this.upScore === 0) {
      this.levelUp();
    }
  }

  levelUp() {
    if(this.level > this.maxLevel) return;
    this.level ++;
    this.levelEl.innerText = this.level + '';
  }

}


export default ScorePanel;